class Solution(object):
    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        m = -10001
        c = 0
        for num in nums:
            c += num
            if c > m:
                m = c
            if c < 0:
                c = 0
        return m

s = Solution()
nums = [-2,1,-3,4,-1,2,1,-5,4]
result = s.maxSubArray(nums)
print(result)

nums = [1]
result = s.maxSubArray(nums)
print(result)

nums = [5,4,-1,7,8]
result = s.maxSubArray(nums)
print(result)


            